package com.atguigu.lease.web.admin.custom.converter;


import com.atguigu.lease.model.enums.ItemType;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * ClassName: StringToItemTypeConverter
 * Description:
 *
 * @Auther lpl
 * @Create 2024/7/2 0:05
 * @Version 1.0
 */
@Component
public class StringToItemTypeConverter implements Converter<String, ItemType> {

    @Override
    public ItemType convert(String source) {
        int code = Integer.parseInt(source);
        if(code == 1){
            return ItemType.APARTMENT;
        }
        if(code == 2){
            return  ItemType.ROOM;
        }
        return null;
    }

}
